<?php

class MySQL extends DB
{
	/**
	 * Connect to the MySQL datbase provided that the details are correct!
	 *
	 * @access public
	 * @return boolean true on success
	 */
	function connect()
	{
		if($this->_checkDetails()) {
			// we have valid details to work with
			$conn = mysql_connect($this->_server, $this->_username, $this->_password);
			if($conn) {
				$db = mysql_select_db($this->_database, $conn);
				if($db) {
					$this->_conn = $conn;
					return true;
				}
			}
		}
		return false;
	}
	
	/**
	 * Disconnect from the currently connected database
	 *
	 * @access public
	 * @return boolean true on success
	 */
	function disconnect()
	{
		if($this->_conn != false) {
			mysql_close($this->_conn);
			$this->_conn = false;
			return true;
		}
		return false;
	}
	
	/**
	 * Execute the provided query
	 *
	 * @todo this needs to return the dbresult object, currently it's just returning
	 * mysql's native methods
	 * @access public
	 * @return Mysql Result
	 */
	function run()
	{
		if($this->_sql !== false) {
			echo $this->_sql;
			return mysql_query($this->_sql, $this->_conn);
		}
		return false;
	}
}

?>